package com.oliver.oliveraiagent.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @ClassName SpringAiInvoke
 * @Description TODO
 * @Author snow
 * @Date 2025/5/1 22:58
 **/

/**
 * Spring AI 框架调用 AI 大模型
 */
@Component
public class SpringAiInvoke implements CommandLineRunner {

    @Resource
    private ChatModel dashScopeChatModel;

    @Override
    public void run(String... args) throws Exception {
        AssistantMessage assistantMessage = dashScopeChatModel.call(new Prompt("你好，我是oliver"))
                .getResult()
                .getOutput();

        System.out.println(assistantMessage.getText());
    }
}
